#ifndef FILE_LOCK_H_JW3OFJLSDKF92FJSLAFJ
#define FILE_LOCK_H_JW3OFJLSDKF92FJSLAFJ

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <errno.h>

typedef struct file_lock_t
{
	char* fname;
	int fd;
}file_lock_t;
#define FLOCK_READ  1
#define FLOCK_WRITE 0

file_lock_t* file_lock_new(const char* fname, int fmode);
void file_lock_delete(file_lock_t* me);

int file_lock_require(file_lock_t* me, int readonly);
int file_lock_release(file_lock_t* me);

int file_lock_detect(file_lock_t* me, int readonly);

#endif //FILE_LOCK_H_JW3OFJLSDKF92FJSLAFJ
